#define _CRT_SECURE_NO_WARNINGS 1

#include <vector>
#include <string>
#include <unordered_map>
#include <algorithm>
using namespace std;

class Solution {
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs) {
        unordered_map<string, vector<string>> hash;
        string tmp;
        for (auto& str : strs)
        {
            tmp = str;
            sort(tmp.begin(), tmp.end());
            hash[tmp].push_back(str);
        }
        vector<vector<string>> ret;
        for (auto& v : hash)
        {
            ret.push_back(v.second);
        }
        return ret;
    }
};